class Node:
    def __init__(self, val):
        self.val = val
        self.pre = None
        self.next = None


class MyCircularDeque(object):

    def __init__(self, k):
        """
        :type k: int
        """
        self.stack = [0] * k
        self.k = k
        self.count = 0
        self.head = Node(-1)
        self.last = Node(-1)
        self.head.next = self.last
        self.last.pre = self.head

    def insertFront(self, value):
        """
        :type value: int
        :rtype: bool
        """
        if not self.isFull():
            head_next = self.head.next
            node = Node(value)
            self.head.next = node
            node.pre = self.head
            node.next = head_next
            head_next.pre = node
            self.count += 1
            return True
        else:
            return False

    def insertLast(self, value):
        """
        :type value: int
        :rtype: bool
        """
        if not self.isFull():
            last_next = self.last.pre
            node = Node(value)
            node.next = self.last
            self.last.pre = node
            last_next.next = node
            node.pre = last_next
            self.count += 1
            return True
        else:
            return False

    def deleteFront(self):
        """
        :rtype: bool
        """
        if self.isEmpty():
            return False
        else:
            next_node = self.head.next.next
            self.head.next = next_node
            next_node.pre = self.head
            self.count -= 1
            return True

    def deleteLast(self):
        """
        :rtype: bool
        """
        if self.isEmpty():
            return False
        else:
            last_node = self.last.pre.pre
            last_node.next = self.last
            self.last.pre = last_node
            self.count -= 1
            return True

    def getFront(self):
        """
        :rtype: int
        """
        return self.head.next.val

    def getRear(self):
        """
        :rtype: int
        """
        return self.last.pre.val

    def isEmpty(self):
        """
        :rtype: bool
        """
        if self.count:
            return False
        else:
            return True

    def isFull(self):
        """
        :rtype: bool
        """
        return self.count == self.k
